package com.atguigu.yygh.user.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.model.user.UserInfo;
import com.atguigu.yygh.user.service.UserInfoService;
import com.atguigu.yygh.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author luoyin
 * @Date 10:57 2022/10/6
 **/
@RestController
@RequestMapping("/admin/userInfo")
public class AdminUserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @GetMapping("/{pageNum}/{pageSize}")
    public R page(@PathVariable Integer pageNum , @PathVariable Integer pageSize , UserInfoQueryVo userInfoQueryVo){
       Page<UserInfo> page =  userInfoService.findPageList(pageNum,pageSize,userInfoQueryVo);
        return R.ok().data("page",page);
    }

    //修改账号状态
    @PutMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable Long id , @PathVariable Integer status){
        userInfoService.updateStatus(id,status);
        return R.ok();
    }

    //修改实名认证状态
    @PutMapping("/updateAuthStatus/{id}/{authStatus}")
    public R updateAuthStatus(@PathVariable Long id , @PathVariable Integer authStatus){
        userInfoService.updateAuthStatus(id,authStatus);
        return R.ok();
    }
    //查询账号的用户信息以及就诊人信息
    @GetMapping("/detail/{userId}")
    public R detail(@PathVariable Long userId){
        Map<String,Object> map = userInfoService.detail(userId);
        return R.ok().data(map);
    }
}
